//
//  BSKTheme.m
//  MicroMemory
//
//  Created by rimi on 16/7/8.
//  Copyright © 2016年 BlueSky. All rights reserved.
//

#import "BSKTheme.h"
#import "UIImage+BSKGetMainColor.h"

@interface BSKTheme ()
@property(nonatomic,strong) UIColor * themeColor;
@end

@implementation BSKTheme

- (instancetype)initWithThemeImage:(UIImage *)image
{
	self = [super init];
	if (self) {
		self.themeImage = image;
	}
	return self;
}

+(BSKTheme *)curentTheme{
	static BSKTheme * shareTheme = nil;
	if (!shareTheme){
		shareTheme = [[BSKTheme alloc] initWithThemeImage:[UIImage imageNamed:@"paper1"]];
	}
	return shareTheme;
}

-(void)setThemeColor:(UIColor *)themeColor{
	CGFloat red = 0;
	CGFloat green = 0;
	CGFloat blue = 0;
	CGFloat alpha = 0;
	
	_themeColor = themeColor;
	[_themeColor getRed:&red green:&green blue:&blue alpha:&alpha];
	_noteBackgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:0.3];
	red+=0.2;
	green += 0.2;
	blue +=0.2;
	if (red>1) {
		red = 1;
	}
	if (blue > 1) {
		blue = 1;
	}
	if (green > 1) {
		green = 1;
	}
	_menuThemeColors = @[(id)_themeColor.CGColor,(id)[UIColor colorWithRed:red green:green blue:blue alpha:alpha].CGColor,(id)_themeColor.CGColor];
}

-(void)setThemeImage:(UIImage *)themeImage {
    if (themeImage) {
        self.themeColor = [themeImage MainColorOfImage];
        _themeImage = themeImage;
    }
}

@end
